package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.AnnualPriceDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.AnnualySharePriceData;
import org.sixtynine.stock.service.AnnualPriceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class AnnualPriceDataServiceImpl implements AnnualPriceDataService {

	@Autowired
	private AnnualPriceDataDao annualShareDataDao;

	@Override
	public AnnualySharePriceData findById(int id) {
		return annualShareDataDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveAnnualySharePriceData(AnnualySharePriceData annualShareData) {
		annualShareDataDao.saveAnnualySharePriceData(annualShareData);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteAnnualySharePriceData(int id) {
		AnnualySharePriceData annualShareData = annualShareDataDao.findById(id);
		if (annualShareData != null) {
			annualShareDataDao.delete(annualShareData);
		}
	}

	@Override
	public List<AnnualySharePriceData> findAnnualySharePriceData(int companyId) {
		return annualShareDataDao.findAnnualySharePriceData(companyId);
	}

	@Override
	public List<AnnualySharePriceData> searchAnnualySharePriceData(
			int companyId, Date fromYear, Date toYear, String orderBy,
			String orderByName) {
		return annualShareDataDao.searchAnnualySharePriceData(companyId,
				fromYear, toYear, orderBy, orderByName);
	}

	@Override
	public Page<AnnualySharePriceData> searchAnnualySharePriceData(
			int companyId, Date fromYear, Date toYear, String orderBy,
			String orderByName, GridPramDTO gridPramDTO) {
		return annualShareDataDao.searchAnnualySharePriceData(companyId,
				fromYear, toYear, orderBy, orderByName, gridPramDTO);
	}

	@Override
	public void deleteAnnualySharePriceData(int companyId, Date fromDate,
			Date toDate) {
		annualShareDataDao.deleteAnnualySharePriceData(companyId, fromDate, toDate);
	}

}
